package demo03.ObserverModel;


/**
 * 目前（天气）状况显示实体类(观察者)
 * */
public class CurrentConditionsDisplay implements Observer,DisplayElement{
	private float temp; //温度
	private float humidity;//湿度
	private float pressure;//气压
	private Subject weatherData;//主题接口
	
	
	//构造器，传入主题
	public CurrentConditionsDisplay(Subject weatherData) {
		this.weatherData =weatherData;
		weatherData.registerObserver(this);//注册
	}


	public void display() {
		System.out.println("当前天气状态:温度"+temp+",湿度:"+humidity);
	}

	
	public void update(float temp, float humidity, float pressure) {
		this.temp =temp;
		this.humidity = humidity;
		//当调用update是我们把温度和湿度保存起来然后调用display
		display();
	}

}
